<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>访问日志</title>
    <link rel="stylesheet" href="../assets/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../assets/style/admin.css">
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <script src="../assets/layui/layui.js"></script>
    <script src="../assets/js/common.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <script src="../common/header.js"></script>
    <!-- 内容主体区域 -->
    <div id="LAY_app_body">
        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-body">
                            <div class="">
                                <div class="layui-form-inline">
                                    <div class="layui-input-inline">
                                        <input type="text" name="search" class="layui-input" id="search"
                                               placeholder="搜索用户名" autocomplete="off" class="">
                                    </div>
                                    <div class="layui-input-inline">
                                        <input type="text" id="start_time" name="start_time" autocomplete="off"
                                               placeholder="请输入开始时间" class="layui-input">
                                    </div>
                                    -
                                    <div class="layui-input-inline">
                                        <input type="text" id="end_time" name="end_time" autocomplete="off"
                                               placeholder="请输入结束时间" class="layui-input">
                                    </div>
                                    <button class="layui-btn layui-btn-xs" onclick="reloadList();">搜索</button>
                                    <button class="layui-btn layui-btn-xs layui-btn-primary"
                                            onclick="reloadList(true);">重置
                                    </button>
                                </div>
                            </div>
                            <table class="layui-hide" id="LAY-user-manage" lay-filter="LAY-user-manage"></table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        var reloadList;
        layui.use(['form', 'table'], function () {
            var $ = layui.$
                , form = layui.form
                , layer = layui.layer
                , table = layui.table;
            layui.use('laydate', function () {
                var laydate = layui.laydate;
                var endDate = laydate.render({
                    elem: '#end_time',//选择器结束时间
                    type: 'datetime',
                    min: "1970-1-1",//设置min默认最小值
                    done: function (value, date) {
                        startDate.config.max = {
                            year: date.year,
                            month: date.month - 1,//关键
                            date: date.date,
                            hours: 0,
                            minutes: 0,
                            seconds: 0
                        }
                    }
                });
                //日期范围
                var startDate = laydate.render({
                    elem: '#start_time',
                    type: 'datetime',
                    max: "2099-12-31",//设置一个默认最大值
                    done: function (value, date) {
                        endDate.config.min = {
                            year: date.year,
                            month: date.month - 1, //关键
                            date: date.date,
                            hours: 0,
                            minutes: 0,
                            seconds: 0
                        };
                    }
                });
            });

            table.render({
                elem: '#LAY-user-manage'
//            ,height: 'full-200'
                , url: '' //数据接口
                , page: true //开启分页
                , cols: [[ //表头
                    {field: 'id', title: 'ID', width: 80, sort: true, fixed: 'left'}
                    , {field: 'ip', title: 'IP', width: 170}
                    , {field: 'created', title: '访问时间', width: 170}
                    , {field: 'remark', title: '备注'}
                ]]
                , data: [
                        {
                            "id": "164420",
                            "user_id": "1092",
                            "class": "log",
                            "action": "userActionLogList",
                            "created": "2019-11-18 21:57:26",
                            "ip": "112.45.163.141",
                            "username": "ceshi-000",
                            "remark": "ceshi-000\u8bbf\u95ee: \u7528\u6237\u8bbf\u95ee\u65e5\u5fd7\u5217\u8868",
                            "roles": " \u7528\u6237"
                        }, {
                        "id": "164415",
                        "user_id": "1092",
                        "class": "log",
                        "action": "userActionLog",
                        "created": "2019-11-18 21:57:22",
                        "ip": "112.45.163.141",
                        "username": "ceshi-000",
                        "remark": "ceshi-000\u8bbf\u95ee: \u7528\u6237\u8bbf\u95ee\u65e5\u5fd7",
                        "roles": " \u7528\u6237"
                    }, {
                        "id": "164262",
                        "user_id": "1092",
                        "class": "batch_change_wechat_info",
                        "action": "index",
                        "created": "2019-11-18 21:54:53",
                        "ip": "112.45.163.141",
                        "username": "ceshi-000",
                        "remark": "ceshi-000\u8bbf\u95ee: \u6279\u91cf\u8bbe\u7f6e\u4fee\u6539\u5fae\u4fe1\u4fe1\u606f",
                        "roles": " \u7528\u6237"
                    }, {
                        "id": "164251",
                        "user_id": "1092",
                        "class": "batch_change_wechat_info",
                        "action": "index",
                        "created": "2019-11-18 21:54:35",
                        "ip": "112.45.163.141",
                        "username": "ceshi-000",
                        "remark": "ceshi-000\u8bbf\u95ee: \u6279\u91cf\u8bbe\u7f6e\u4fee\u6539\u5fae\u4fe1\u4fe1\u606f",
                        "roles": " \u7528\u6237"
                    }, {
                        "id": "164242",
                        "user_id": "1092",
                        "class": "group",
                        "action": "index",
                        "created": "2019-11-18 21:54:24",
                        "ip": "112.45.163.141",
                        "username": "ceshi-000",
                        "remark": "ceshi-000\u8bbf\u95ee: \u5fae\u4fe1\u7ec4\u5217\u8868",
                        "roles": " \u7528\u6237"
                    }, {
                        "id": "164238",
                        "user_id": "1092",
                        "class": "group",
                        "action": "list_data",
                        "created": "2019-11-18 21:54:21",
                        "ip": "112.45.163.141",
                        "username": "ceshi-000",
                        "remark": "ceshi-000\u8bbf\u95ee: \u5fae\u4fe1\u7ec4\u5217\u8868\u6570\u636e\u52a0\u8f7d",
                        "roles": " \u7528\u6237"
                    }, {
                        "id": "164237",
                        "user_id": "1092",
                        "class": "group",
                        "action": "index",
                        "created": "2019-11-18 21:54:17",
                        "ip": "112.45.163.141",
                        "username": "ceshi-000",
                        "remark": "ceshi-000\u8bbf\u95ee: \u5fae\u4fe1\u7ec4\u5217\u8868",
                        "roles": " \u7528\u6237"
                    }, {
                        "id": "164236",
                        "user_id": "1092",
                        "class": "batch_change_wechat_info",
                        "action": "index",
                        "created": "2019-11-18 21:54:14",
                        "ip": "112.45.163.141",
                        "username": "ceshi-000",
                        "remark": "ceshi-000\u8bbf\u95ee: \u6279\u91cf\u8bbe\u7f6e\u4fee\u6539\u5fae\u4fe1\u4fe1\u606f",
                        "roles": " \u7528\u6237"
                    }, {
                        "id": "163948",
                        "user_id": "1092",
                        "class": "wechat_rule",
                        "action": "batchEdit",
                        "created": "2019-11-18 21:49:33",
                        "ip": "112.45.163.141",
                        "username": "ceshi-000",
                        "remark": "ceshi-000\u8bbf\u95ee: \u6279\u91cf\u8bbe\u7f6e\u52a0\u597d\u53cb\u89c4\u5219",
                        "roles": " \u7528\u6237"
                    }, {
                        "id": "163945",
                        "user_id": "1092",
                        "class": "wechat_rule",
                        "action": "batchEdit",
                        "created": "2019-11-18 21:49:28",
                        "ip": "112.45.163.141",
                        "username": "ceshi-000",
                        "remark": "ceshi-000\u8bbf\u95ee: \u6279\u91cf\u8bbe\u7f6e\u52a0\u597d\u53cb\u89c4\u5219",
                        "roles": " \u7528\u6237"
                    }]
                , title: '记录列表'
                , toolbar: true
                , defaultToolbar: ['filter']
            });

            reloadList = function (reset) {
                if (reset == true) {
                    $('#search').val('');
                    $('#start_time').val('');
                    $('#end_time').val('');
                }
                var search = $('#search').val();
                var startDate = $('#start_time').val();
                var endDate = $('#end_time').val();
                table.reload('LAY-user-manage', {
                    where: { //设定异步数据接口的额外参数，任意设
                        search: search,
                        startDate: startDate,
                        endDate: endDate,
                    }
                    , page: {
                        curr: 1 //重新从第 1 页开始
                    }
                });
            };
        });

    </script>
    <script type="text/html" id="created">
</script>
</div>
</body>
</html>
